package com.xsr.controller;

import com.xsr.pojo.User;
import com.xsr.service.UserService;
import com.xsr.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project peopleThing
 * @date 2022/9/10 17:32
 */
@Controller
@RequestMapping("/User")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/login")
    public String login(String username, String password){
        if( userService.findByUsernameAndPwd(username,password)){

            return "forward:/profile/main";
        }
        return "regist";
    }
    @RequestMapping("/regist")
    public  String regist(User user){
        userService.addUser(user);
        return "redirect:/index.jsp";
    }
    @RequestMapping("/register")
    public  String register(){

        return "regist";
    }
}
